home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-SPAR.{_6 / SMP.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  5KB  |  186 lines

  1. /* smp.h: Sparc specific SMP stuff.
  2.  *
  3.  * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
  4.  */
  5.  
  6. #ifndef _SPARC_SMP_H
  7. #define _SPARC_SMP_H
  8.  
  9. #include <linux/tasks.h>
  10. #include <asm/head.h>
  11. #include <asm/btfixup.h>
  12.  
  13. #ifndef __ASSEMBLY__
  14. /* PROM provided per-processor information we need
  15.  * to start them all up.
  16.  */
  17.  
  18. struct prom_cpuinfo {
  19.     int prom_node;
  20.     int mid;
  21. };
  22. extern int linux_num_cpus;    /* number of CPUs probed  */
  23.  
  24. #endif /* !(__ASSEMBLY__) */
  25.  
  26. #ifdef __SMP__
  27.  
  28. #ifndef __ASSEMBLY__
  29.  
  30. #include <asm/ptrace.h>
  31. #include <asm/asi.h>
  32.  
  33. extern struct prom_cpuinfo linux_cpus[NR_CPUS];
  34.  
  35. /* Per processor Sparc parameters we need. */
  36.  
  37. struct cpuinfo_sparc {
  38.     unsigned long udelay_val; /* that's it */
  39.     unsigned short next;
  40.     unsigned short mid;
  41. };
  42.  
  43. extern struct cpuinfo_sparc cpu_data[NR_CPUS];
  44. extern unsigned long cpu_offset[NR_CPUS];
  45.  
  46. /*
  47.  *    Private routines/data
  48.  */
  49.  
  50. extern int smp_found_cpus;
  51. extern unsigned char boot_cpu_id;
  52. extern unsigned long cpu_present_map;
  53.  
  54. typedef void (*smpfunc_t)(unsigned long, unsigned long, unsigned long,
  55.                unsigned long, unsigned long);
  56.  
  57. /*
  58.  *    General functions that each host system must provide.
  59.  */
  60.  
  61. void sun4m_init_smp(void);
  62. void sun4d_init_smp(void);
  63.  
  64. void smp_callin(void);
  65. void smp_boot_cpus(void);
  66. void smp_store_cpu_info(int);
  67.  
  68. int smp_bogo_info(char *buf);
  69. int smp_info(char *buf);
  70.  
  71. BTFIXUPDEF_CALL(void, smp_cross_call, smpfunc_t, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long)
  72. BTFIXUPDEF_CALL(void, smp_message_pass, int, int, unsigned long, int)
  73. BTFIXUPDEF_CALL(int, __smp_processor_id, void)
  74. BTFIXUPDEF_BLACKBOX(smp_processor_id)
  75. BTFIXUPDEF_BLACKBOX(load_current)
  76.  
  77. #define smp_cross_call(func,arg1,arg2,arg3,arg4,arg5) BTFIXUP_CALL(smp_cross_call)(func,arg1,arg2,arg3,arg4,arg5)
  78. #define smp_message_pass(target,msg,data,wait) BTFIXUP_CALL(smp_message_pass)(target,msg,data,wait)
  79.  
  80. extern __inline__ void xc0(smpfunc_t func) { smp_cross_call(func, 0, 0, 0, 0, 0); }
  81. extern __inline__ void xc1(smpfunc_t func, unsigned long arg1)
  82. { smp_cross_call(func, arg1, 0, 0, 0, 0); }
  83. extern __inline__ void xc2(smpfunc_t func, unsigned long arg1, unsigned long arg2)
  84. { smp_cross_call(func, arg1, arg2, 0, 0, 0); }
  85. extern __inline__ void xc3(smpfunc_t func, unsigned long arg1, unsigned long arg2,
  86.                unsigned long arg3)
  87. { smp_cross_call(func, arg1, arg2, arg3, 0, 0); }
  88. extern __inline__ void xc4(smpfunc_t func, unsigned long arg1, unsigned long arg2,
  89.                unsigned long arg3, unsigned long arg4)
  90. { smp_cross_call(func, arg1, arg2, arg3, arg4, 0); }
  91. extern __inline__ void xc5(smpfunc_t func, unsigned long arg1, unsigned long arg2,
  92.                unsigned long arg3, unsigned long arg4, unsigned long arg5)
  93. { smp_cross_call(func, arg1, arg2, arg3, arg4, arg5); }
  94.  
  95. extern __volatile__ int cpu_number_map[NR_CPUS];
  96. extern __volatile__ int __cpu_logical_map[NR_CPUS];
  97. extern unsigned long smp_proc_in_lock[NR_CPUS];
  98.  
  99. extern __inline__ int cpu_logical_map(int cpu)
  100. {
  101.     return __cpu_logical_map[cpu];
  102. }
  103.  
  104. extern __inline__ int hard_smp4m_processor_id(void)
  105. {
  106.     int cpuid;
  107.  
  108.     __asm__ __volatile__("rd %%tbr, %0\n\t"
  109.                  "srl %0, 12, %0\n\t"
  110.                  "and %0, 3, %0\n\t" :
  111.                  "=&r" (cpuid));
  112.     return cpuid;
  113. }
  114.  
  115. extern __inline__ int hard_smp4d_processor_id(void)
  116. {
  117.     int cpuid;
  118.  
  119.     __asm__ __volatile__("lda [%%g0] %1, %0\n\t" :
  120.                  "=&r" (cpuid) : "i" (ASI_M_VIKING_TMP1));
  121.     return cpuid;
  122. }
  123.  
  124. #ifndef MODULE
  125. extern __inline__ int hard_smp_processor_id(void)
  126. {
  127.     int cpuid;
  128.  
  129.     /* Black box - sun4m
  130.         __asm__ __volatile__("rd %%tbr, %0\n\t"
  131.                      "srl %0, 12, %0\n\t"
  132.                      "and %0, 3, %0\n\t" :
  133.                      "=&r" (cpuid));
  134.                  - sun4d
  135.            __asm__ __volatile__("lda [%g0] ASI_M_VIKING_TMP1, %0\n\t"
  136.                         "nop; nop" :
  137.                         "=&r" (cpuid));
  138.        See btfixup.h and btfixupprep.c to understand how a blackbox works.
  139.      */
  140.     __asm__ __volatile__("sethi %%hi(___b_smp_processor_id), %0\n\t"
  141.                  "sethi %%hi(boot_cpu_id), %0\n\t"
  142.                  "ldub [%0 + %%lo(boot_cpu_id)], %0\n\t" :
  143.                  "=&r" (cpuid));
  144.     return cpuid;
  145. }
  146. #else
  147. extern __inline__ int hard_smp_processor_id(void)
  148. {
  149.     int cpuid;
  150.     
  151.     __asm__ __volatile__("mov %%o7, %%g1\n\t"
  152.                  "call ___f___smp_processor_id\n\t"
  153.                  " nop\n\t"
  154.                  "mov %%g2, %0\n\t" : "=r"(cpuid) : : "g1", "g2");
  155.     return cpuid;
  156. }
  157. #endif
  158.  
  159. #define smp_processor_id() hard_smp_processor_id()
  160. extern __inline__ void smp_send_reschedule(int cpu) { }
  161. extern __inline__ void smp_send_stop(void) { }
  162.  
  163. #endif /* !(__ASSEMBLY__) */
  164.  
  165. /* Sparc specific messages. */
  166. #define MSG_CROSS_CALL         0x0005       /* run func on cpus */
  167.  
  168. /* Empirical PROM processor mailbox constants.  If the per-cpu mailbox
  169.  * contains something other than one of these then the ipi is from
  170.  * Linux's active_kernel_processor.  This facility exists so that
  171.  * the boot monitor can capture all the other cpus when one catches
  172.  * a watchdog reset or the user enters the monitor using L1-A keys.
  173.  */
  174. #define MBOX_STOPCPU          0xFB
  175. #define MBOX_IDLECPU          0xFC
  176. #define MBOX_IDLECPU2         0xFD
  177. #define MBOX_STOPCPU2         0xFE
  178.  
  179. #define PROC_CHANGE_PENALTY     15
  180.  
  181. #endif /* !(__SMP__) */
  182.  
  183. #define NO_PROC_ID            0xFF
  184.  
  185. #endif /* !(_SPARC_SMP_H) */
  186.